package com.baizhi.service.impl;

import com.baizhi.dao.CmfzArticleDao;
import com.baizhi.entity.CmfzArticle;
import com.baizhi.service.CmfzArticleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
@Transactional
public class CmfzArticleServiceImpl implements CmfzArticleService {
    @Autowired
    private CmfzArticleDao cmfzArticleDao;

    @Override
    public void insertCmfzArticle(CmfzArticle cmfzArticle) {
        cmfzArticleDao.insert(cmfzArticle);
    }

    @Override
    public void deleteCmfzArticle(Integer id) {
        cmfzArticleDao.deleteById(id);
    }

    @Override
    @Transactional(readOnly = true)
    public CmfzArticle selectById(Integer id) {
        return cmfzArticleDao.selectById(id);
    }

    @Override
    public void updaetCmfzArticle(CmfzArticle cmfzArticle) {
        cmfzArticleDao.updateById(cmfzArticle);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<CmfzArticle> selectByPage(Integer page, Integer limit) {
        Page<CmfzArticle> cmfzArticlePage = new Page<>(page, limit);
        return cmfzArticleDao.selectPage(cmfzArticlePage,null);
    }
}
